import { API_URL } from "../constants";
import type { ILimitWarning, IResponse } from "../types";
import request from "./request";

export function getLimitWarning(token: string) {
  return request<IResponse<{ data: ILimitWarning }>>(
    `${API_URL}/business/limitWarning/`,
    {
      headers: { Authorization: token },
    },
  );
}

export function updateLimitWarning(
  data: Pick<
    ILimitWarning,
    | "hWarningLimitLower"
    | "hWarningLimitUpper"
    | "pWarningLimitLower"
    | "pWarningLimitUpper"
    | "tWarningLimitLower"
    | "tWarningLimitUpper"
  >,
  token: string,
) {
  return request<IResponse>(`${API_URL}/business/limitWarning`, {
    method: "put",
    data,
    headers: { Authorization: token },
  });
}
